package be.bejug.scrumadmin.fieldfactory;

import be.bejug.scrumadmin.spring.ApplicationHolder;

import com.vaadin.data.Item;
import com.vaadin.ui.Component;
import com.vaadin.ui.Field;
import com.vaadin.ui.FormFieldFactory;
import com.vaadin.ui.PasswordField;
import com.vaadin.ui.TextField;

public class LoginFormFieldFactory implements FormFieldFactory {

	/**
	 * Serial Version UID.
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Field createField(final Item item, final Object propertyId,
			final Component uiContext) {
		String pid = (String) propertyId;
		if (pid.equals("password")) {
			return new PasswordField(
					ApplicationHolder.getMessage("textfield.label.password"));
		} else if (pid.equals("username")) {
			return new TextField(
					ApplicationHolder.getMessage("textfield.label.username"));
		}
		return null;
	}

}
